import App from "../views/app.vue";
// import store from '../store'
// import config from './config'

import lazyLoading from "src/config/lazyLoading.js";
export const config = {
  routers: {
    items: [
      {
        name: "pc",
        path: "/pc",
        meta: {
          title: "PC页面",
          link: "mobile/index.vue"
        },
        component: lazyLoading("pc", true)
      },
      {
        name: "appDeal",
        path: "/appDeal",
        meta: {
          title: "appDeal",
          link: "mobile/appDeal.vue"
        },
        component: lazyLoading("mobile/appDeal")
      },
      {
        name: "appFind",
        path: "/appFind",
        meta: {
          title: "appFind",
          link: "mobile/appFind.vue"
        },
        component: lazyLoading("mobile/appFind")
      },
      {
        name: "appInformation",
        path: "/appInformation",
        meta: {
          title: "appInformation",
          link: "mobile/appInformation.vue"
        },
        component: lazyLoading("mobile/appInformation")
      },
      {
        name: "appLogin",
        path: "/appLogin",
        meta: {
          title: "appLogin",
          link: "mobile/appLogin.vue"
        },
        component: lazyLoading("mobile/appLogin")
      },
      {
        name: "appMine",
        path: "/appMine",
        meta: {
          title: "appMine",
          link: "mobile/appMine.vue"
        },
        component: lazyLoading("mobile/appMine")
      }
    ]
  }
};

/**
 * 配置多入口页面 挂载组件等
 */
export default [
  {
    path: "/",
    component: App,
    children: [
      {
        path: "/", //首页
        name: "/",
        meta: { title: "首页" },
        component: lazyLoading("mobile", true)
      },
      ...generateRoutesFromMenu(config.routers.items)
    ]
  }
];

// Menu should have 2 levels.
function generateRoutesFromMenu(menu = [], routes = []) {
  for (let i = 0, l = menu.length; i < l; i++) {
    let item = menu[i];
    if (item.path) {
      routes.push(item);
    }
    if (!item.component) {
      generateRoutesFromMenu(item.children, routes);
    }
  }
  return routes;
}
